package cn.edu.xmu.restfuldemo.model;

import cn.edu.xmu.restfuldemo.model.Product;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;

/**
 * 商品规格视图对象
 * @author Ming Qiu
 **/
@Data
@ApiModel(description = "商品规格视图对象")
public class ProductRetVo {

    @ApiModelProperty(value = "规格id")
    private Integer id;

    @ApiModelProperty(value = "规格序号")
    private String skuSn;

    @ApiModelProperty(value = "描述")
    private String name;

    @ApiModelProperty(value = "零售价")
    private Integer originalPrice;

    @ApiModelProperty(value = "促销价")
    private Integer price;

    @ApiModelProperty(value = "重量(克)")
    private Integer weight;

//    @ApiModelProperty(value = "库存量")
//    private Integer stock;

    @ApiModelProperty(value = "规格状态")
    private Integer state;



    @ApiModelProperty(value = "货品详情")
    private String detail;

    @ApiModelProperty(value = "封面URL")
    private String imageUrl;

    @ApiModelProperty(value = "详细目录")
    private Integer inventory;


    private String gmtCreate;
    private String gmtModified;

//    public GoodsRetVo getGoods() {
//        return goods;
//    }

    @ApiModelProperty("所属商品")
    private GoodsRetVo goods;

    @ApiModelProperty("是否禁止访问")
    private boolean disabled;

    @ApiModelProperty("是否允许分享")
    private boolean shareable;





    /**
     * 由Vo对象创建Product对象
     * @return Product对象
     */
    public ProductRetVo(Product product){
        this.id = product.getId();
        this.skuSn = product.getProductSn();
        this.originalPrice = product.getOriginalPrice();
        this.price = product.getCounterPrice();
        this.weight = product.getWeight();
        this.name = product.getName();
//        this.stock = product.getStock();
        this.state = product.getState().getCode();
        this.detail = null;
        this.imageUrl = null;
        this.inventory = null;
        this.gmtCreate=null;
        this.gmtModified = null;

        this.disabled = false;
        this.shareable = false;

         Integer goodsId = product.getProductPo().getGoodsId();
         System.out.println(goodsId);
         this.goods = new GoodsRetVo();
        this.goods.setId(goodsId);

    }
}
